'; window.popUpWin.document.write(zhtm); window.popUpWin.document.close(); // Johnny Jackson 4/28/98 } //--> Inside AutoCAD 14 -- Ch 12 -- Creating and Using Blocks


Inside AutoCAD 14

Previous chapterNext chapterContents


- 12 -

Creating and Using Blocks


by Bill Burchard

Blocks are a very powerful feature of AutoCAD. They enable you to define an object or collection of objects that can be inserted into a drawing over and over, without having to redraw the objects again from scratch. They provide the capability to significantly reduce a drawing's file size. More importantly, although a drawing may contain hundreds of insertions of a particular block, if it becomes necessary to edit the blocks, AutoCAD requires only that you edit the original block definition. Once redefined, the hundreds of instances of the inserted block will automatically be updated. The new changes will appear instantly. Additionally, attributes can be attached to a block, providing a means to create, and then extract, useful data unique to a particular block insertion.

To use the power of blocks to their fullest capabilities, it is necessary to first understand the nature of blocks. By understanding how blocks work, and how to properly manage blocks, you will learn how to make AutoCAD do tedious, repetitious tasks automatically, thereby increasing your productivity.

This chapter discusses the following subjects:

Understanding Blocks

A block is a collection of individual objects combined into a larger single object. Think of the block as the parent of a family, and the individual objects as the parent's children. Although the children have identities of their own (color, layer, and linetype), they are also under the control of their parent, which also has its own color, layer, and linetype properties.

The fact that both the block (parent) and its individual objects (children) have their own color, layer, and linetype properties makes it important to understand how these properties are affected by certain conditions. For example, assume that a block has been created from several child objects, and that each child object was originally created on its own layer. The layers on which the child objects were created can be frozen individually. If one of these layers is frozen, the child object that was created on that layer will also be frozen and become invisible. However, the other child objects will still be visible because the layers they are on are still thawed. In contrast, if the parent block is inserted on its own layer, and that layer is then frozen, all its child objects will also be frozen. This is true even though the layers of the child objects are thawed.

For example, figure 12.1 shows an inserted block made up of three child objects. The parent block is inserted on layer Parent. The rectangle, triangle, and circle were on layers of Rectangle, Triangle, and Circle, respectively, when they were selected to define the block.

Figure 12.1 The parent block with its three child objects.

When the Triangle layer is frozen, as shown in figure 12.2, only the triangle child object disappears. This is true even though the triangle is part of another object--the inserted block object.

In contrast, all the child objects disappear when the Parent layer is frozen, as shown in figure 12.3. This demonstrates the difference between freezing a child object's layer versus its parent's layer.

Figure 12.2 The parent block with the Triangle layer frozen.

Figure 12.3 The inserted block disappears when the Parent layer is frozen.

This example is just one of several different conditions that can influence the behavior and appearance of a block. Understanding the rules that govern these conditions is essential to extracting the power of blocks and to increasing your productivity.

Defining Blocks

What happens inside a drawing when a new block is defined? If you have created blocks before, you know that once you select the child objects that make up the block, they all disappear from the screen. This happens because AutoCAD automatically erases them once they have been used to define a block.


TIP: Use the OOPS command to unerase the objects. The OOPS command can always be used to unerase the last object erased. This is true even if several other commands have been executed after an object is erased.


NOTE: I always thought it silly that AutoCAD erased the objects. After all, I typically created the objects where I needed them in the first place. I was only trying to make a copy of the objects to put someplace else in my drawing. Why, then, would it erase them? The following paragraph explains.

There is a logical reason why AutoCAD erases the objects. The block command is more than another COPY command. Instead, it is a way of making copies of a collection of child objects that uses less file space. It keeps the file size of an AutoCAD drawing smaller by storing each child object's property data in a place AutoCAD calls the Block Table. It stores this information under the name of the parent block. When a block is inserted into AutoCAD, instead of duplicating the property data of each child object (as the COPY command does), AutoCAD simply refers back to the property data stored in the Block Table. It then draws the child objects based upon this data. This enables AutoCAD to store each child object's property data in just one place, the Block Table. You can therefore insert multiple copies of a block, duplicating the child objects where needed. In each case, AutoCAD refers back to the Block Table for the data it needs to draw the child objects. Consequently, AutoCAD erases the original objects once they are used to define a block because it assumes you will want to reinsert those objects as a block, reducing the file size of your drawing.


NOTE: AutoCAD R14 has a new command called BMAKE. This command opens the Block Definition dialog box shown in figure 12.4. Its features enable you to do the following:

Specify the name of the block

Specify the insertion base point for the block

Specify the objects to include in the new block

List block names in a separate dialog box

Prevent objects used to define the block from being erased


Figure 12.4 The Block Definition dialog box displayed with the BMAKE command.

The following exercise shows how AutoCAD stores block data in the Block Table, and refers to the Block Table to draw instances of child objects.

VIEWING THE BLOCK TABLE'S DATA

1. Open the 12DWG01.DWG drawing file on the accompanying CD.

This drawing consists of five objects: the circle, triangle, and rectangle objects along the top of the screen, and the two inserted block objects along the bottom of the screen. The child objects of both block insertions are made from the three objects along the top of the screen.

2. Next, choose Tools, Inquiry, List to list the database information for the circle object and the inserted block object on the lower left.

3. Select the circle object in the upper-left corner.

4. Select the circle child object of the inserted block in the lower-left corner, and then end object selection.

5. The AutoCAD Text Window displays the data list, as shown in figure 12.5. The circle object's data list starts with the title CIRCLE. This indicates what type of AutoCAD object it is. Notice that the inserted block's data list starts with BLOCK REFERENCE. Even though you selected the circle child object, the data list describes its parent's data.

Figure 12.5 The AutoCAD Text Window displays the selected object's data list.


Next, you will use an AutoLISP function to select the three circle objects. This function selects objects, including child objects nested in blocks or xrefs. It then displays the stored data AutoCAD uses to draw the objects on-screen.

6. At the command prompt, type (nentsel), including the parenthesis.

7. Select the circle child object in the inserted block on the lower left.

8. At the command prompt, type (nentsel) again.

9. Select the circle child object in the inserted block on the lower right.

10. At the command prompt, type (nentsel) again.

11. Select the circle object in the upper-left corner.

12. Press F2 to display the AutoCAD Text Window.

The AutoCAD Text Window displays the object's data list. An example of this is shown in figure 12.6. In each data list, AutoCAD displays different types of data in several groups separated by parenthesis. Each data list begins with the entity's name. This name is created by AutoCAD and is saved with the drawing. Each entity name represents a unique object identifier. The same name is never used twice during the life of a drawing. If an entity is erased, AutoCAD retires its entity name.

Figure 12.6 The object data list of the selected circle objects.

Note the entity names at the beginning of each list in figure 12.6. The first two lists display the same entity name, 1fc0548. If AutoCAD never uses the same entity name twice, why does this same name appear twice with two different entities? This occurs because the circle child object chosen in each inserted block refers to the same block of data in the Block Table. Also note that, even though the circle child object was defined with the circle in the upper-left corner, AutoCAD created a new set of circle data for the block definition. That's why the data list for the circle object starts with a different entity name, 1fc0588.

This example demonstrates how block definitions reduce a drawing's file size. By referring to the same object data in the Block Table when drawing the child object, AutoCAD avoids duplicating the object data it would otherwise create using the COPY command.

This example also demonstrates how AutoCAD automatically updates hundreds of block insertions instantly. When an existing block is redefined, the object data in the Block Table that each inserted block object refers to is changed. Consequently, when AutoCAD redraws the inserted block objects, it uses the new data as the guide to draw the child objects.

The Effect of the Current UCS on Block Definitions

When you create a block, you must define its insertion base point. This point's coordinates are relative to the block object, and are set to 0,0,0. Consequently, when defining a block's insertion base point, even though the current UCS (User-defined Coordinate System) coordinates may be 100,100,100 when you pick them, AutoCAD ignores these values and stores the block's insertion base point as 0,0,0. This is true in both paper space and model space. If this block is then exported out as its own drawing using the WBLOCK command, the insertion base point will be at 0,0,0 of the WCS (World Coordinate System) in the new drawing. This feature enables predictable insertion of blocks.

To demonstrate that AutoCAD redefines a block's insertion base point to 0,0,0, the following exercise lists the data values for two different objects. The first object is a circle whose center is at 100,100,100. The second object is a block inserted at 95,100,0. The block definition is made from the same circle. Its insertion base point was defined as the center of the circle.

COMPARING THE CIRCLES' CENTER COORDINATE VALUES

1. Open the 12DWG02.DWG drawing file, which can be found on the accompanying CD.

The drawing contains the two circles. The circle on the right has a center coordinate value of 100,100,100.

Next, you will view the objects data values using AutoLISP functions.


2. At the command prompt, type (entget (car (entsel))).

3. Select the circle on the right.

4. Press F2.

The AutoCAD Text Window opens and displays the data values of the circle object. Inside each set of parenthesis are data values. Each set of parenthesis typically holds two values separated by a period. These represent data pairs. The number on the left is the group code, which indicates the type of data contained in the data pair. The right value is either a number or a text string that indicates the value for the group code.

For example, the 0 group code represents the type of object. In this case, the data is for a CIRCLE object. There exists one set of parenthesis that contain more than a pair of data. Its group code is 10, which indicates this data contains the coordinate values for the object. These are listed in X,Y,Z order, and the coordinate values indicate that the center of this circle is at 100.0,100.0,100.0.

For comparison, you will now use another set of AutoLISP functions to view the data values for the inserted block object.


5. At the command prompt, type (entget (car (entsel))).

6. Select the circle on the left.

7. Press F2.

In this case, the 0 group code indicates that this is an INSERT object, which is a block reference. The 2 group code indicates the name of the block definition used to draw this block. In this case, when the block was defined, it was named C1. Notice the coordinate values of the 10 group code. They are 95.0,100.0,100.0, which is where the block was inserted in model space.

Finally, you are ready to view the child object's coordinate values.


8. At the command prompt, type (entget (car (nentsel))). Note the n character in front of entsel.

The function nentsel stands for nested entity selection. This function can be used to select the child (or nested) objects of blocks. In contrast, the entsel function stands for entity selection, and can be used to select the insert (or parent) object.

9. Select the circle on the left.

10. Press F2.


NOTE: AutoCAD ignores the current UCS coordinate values in paper space and model space when defining a block's insertion base point.

Notice, in this case, the 10 group code coordinate values are 0.0,0.0,0.0. This is because AutoCAD redefines a block's insertion coordinates as 0,0,0. This is true, even though the original circle used to define this block (the circle on the right) has its center coordinates' values defined as 100.0,100.0,100.0. Figure 12.7 shows the results of the previous exercise.

Figure 12.7 The data pairs of the selected objects.


TIP: When defining the insertion base point of a new block, simply imagine that AutoCAD is temporarily redefining the UCS origin to the point you pick.

In addition to understanding how AutoCAD deals with the current UCS's coordinates when defining a block, you must also understand the effect that the current UCS's X axis orientation has on the angle a block assumes when it is inserted into a drawing.

When creating a block, AutoCAD uses the current UCS to determine its insertion angle. This angle is oriented relative to the current UCS's X axis. It then assigns this angle to the block as a WCS X axis. This means that when you define a block, you are assigning its own WCS value. If this block is then exported out as its own drawing using the WBLOCK command, the WCS's X axis direction in the new drawing is the same as the UCS's X axis direction used to define the block. Understanding this property will ensure the proper insertion of blocks you create. Even though you can define a block's rotation upon insertion, commands exist that will automatically insert multiple copies of a block, but do not give the opportunity to set the rotation. In these cases, if the rotation is not set properly when the block is created, you will be forced to edit the rotation of each block individually. Correctly setting the UCS's X axis relative to the block you are creating is important in enabling quick insertion of blocks with minimal input from the user, therefore maintaining a high level of productivity.

To demonstrate the effect of the current UCS's orientation, you will insert two different arrowhead blocks into an existing drawing.

EXAMINING THE EFFECT OF THE CURRENT UCS' ORIENTATION

1. Open the 12DWG03.DWG drawing file on the accompanying CD.

The drawing contains two sets of objects that appear on the right side of your screen. Both sets are made up of a closed polygon in the shape of an arrowhead with a text object inside. The first set was used to create a block definition called AR1. The second set was used to create a block definition called AR2.

It is important to note the X axis orientation relative to the two arrowheads. Both arrowheads were defined as blocks with the same UCS orientation. As a consequence, when you insert each block during this exercise, you will see the effect the current UCS orientation has on the insert objects.

Now, you will insert AR1.


2. From the Insert menu, choose Block. The Insert dialog box opens.

3. Click on the Block button. The Defined Blocks dialog box opens.

4. Select the AR1 block.

5. Click on OK to close the Defined Blocks dialog box, then click on OK to close the Insert dialog box.

The dialog boxes close and the AR1 insert object appears. Notice that the arrowhead is oriented in the same direction as the original AR1 object set that appears in the lower-right side of your screen.

6. Choose a location to insert the arrowhead and accept the default values for scale and rotation.

Now, you will insert AR2.


7. From the Insert menu, choose Block to open the Insert dialog box.

8. Click on the Block button to open the Defined Blocks dialog box.

9. Select the AR2 block.

10. Click on OK to close the Defined Blocks dialog box, then click on OK to close the Insert dialog box.

The dialog boxes close and the AR2 insert object appears. Notice that the arrowhead is oriented in the same direction as the original AR2 object set that appears in the upper-right side of your screen.

11. Choose a location to insert the arrowhead and accept the default values for scale and rotation.

Your drawing should look similar to figure 12.8.


Figure 12.8 The two arrowhead blocks are inserted.

Now you will change the rotation of the WCS about the Z axis. Then, you will redefine the AR2 block.


12. From the Tools menu, choose UCS, Z Axis Rotate.

13. At the prompt, enter 45.

Notice that the X axis arrow is now rotated parallel to the AR2 object set.

14. From the Draw menu, choose Block, Make. The Block Definition dialog box opens.

15. In the Block Name text box, enter AR2.

16. Click on the Select Point button.

17. Using End Point snap, select the arrowhead tip of the AR2 object set.

18. Click on the Select Objects button.

19. Select the two AR2 objects.

20. Click on OK.

21. Click on the Redefine button to close the Warning dialog box.

AutoCAD redefines the AR2 block definition using the current UCS's X axis orientation, and regenerates the drawing. If the AR2 object set was erased from your screen, enter OOPS at the command prompt to unerase it.

Next, you will set the UCS back to the WCS, and insert the AR2 block.


22. From the Tools menu, choose, UCS, World.

23. From the Insert menu, choose, Block to open the Insert dialog box.

24. Click on the Block button to open the Defined Blocks dialog box.

25. Select the AR2 block.

26. Click on OK to close the Defined Blocks dialog box; then click on OK to close the Insert dialog box.

The dialog boxes close and the AR2 Insert object appears. Notice that the arrowhead is now oriented in the same direction as the WCS X axis.

27. Choose a location to insert the arrowhead and accept the default values for scale and rotation.

Your drawing should look similar to figure 12.9.

Figure 12.9 The redefined AR2 block is inserted.

The previous two exercises demonstrate how AutoCAD deals with the current UCS when defining a block. Both the block's Insertion Base Point and the current UCS's X axis affect the way a block will first appear when being inserted. By understanding these two factors, you can control the way a block inserts into your drawing, minimizing user input, while maximizing productivity.


TIP: You can preset the scale and rotation of a block before it is inserted. This feature is useful when you want to see the effect of a scale or rotation angle prior to inserting the block. To take advantage of this feature, type -I at the command prompt to start the command- line version of the Insert command. Select the block to be inserted. When AutoCAD prompts for the insertion point, type S to preset the scale or R to preset the rotation. AutoCAD prompts for the appropriate values, and then continues with the INSERT command's normal prompts. This is useful because you can preview the block after adjustments in scale and/or rotation, and if the scale and/or rotation are not correct, cancel the command and use the S and R sequence again.

Inserting Blocks

Several commands can be used to insert blocks. Understanding the unique features of these commands is important in selecting the right tool for a particular task.

INSERT and DDINSERT

The INSERT and DDINSERT commands are used to insert blocks. The INSERT command prompts for insertion information at the command line, whereas DDINSERT prompts for the same information through dialog boxes. The DDINSERT dialog box interface makes it easy to select blocks already stored in the current drawing's Block Table. DDINSERT also makes it easy to search for blocks stored outside the current drawing by path and drawing name.


TIP: When using script files to perform repetitious tasks, you should use the INSERT command, because script file instructions cannot be passed to a dialog box. This is also true for AutoLISP routines. When inserting blocks during a normal drawing session, you may prefer to use the DDINSERT command.


NOTE: AutoCAD R14 has assigned a new command alias to the DDINSERT command. To open the Insert dialog box, simply type I at the command prompt. To start the INSERT command at the command-line prompt, type -I.

MINSERT versus ARRAY

Sometimes it may be necessary to insert a block as a rectangular array. Two options exist to accomplish this.

MINSERT Command

First, the MINSERT command combines the INSERT and ARRAY commands. When executed, the first command-line prompts are the typical ones for inserting a block. Next appear the typical command-line prompts for creating an array. The exception is MINSERT can only create rectangular arrays. Therefore, no option is available to select a rectangular or polar array.

One drawback to this command is that the MINSERT object cannot be exploded. If the position of its child objects needs to be edited, the MINSERT object must be erased and then reinserted. The advantage to using this command, however, is that the MINSERT object requires less file space to define it, thereby reducing the file size of your drawing. It is important to note that the reduction in file size can be dramatic. For example, a simple block inserted as an array of 100*100 using the MINSERT command will have little impact, if any, on increasing the file's size. In contrast, the block inserted using the ARRAY command can increase the file's size by 1/2 MB or more.

If you have a situation in which you need to insert an array of blocks, and you will not need to explode the objects, I suggest using the MINSERT command. Otherwise, use the ARRAY command discussed in the next section.

ARRAY Command

The ARRAY command accomplishes the same thing as the MINSERT command, only with more capabilities. With the ARRAY command, you have the option of rectangular or polar arrays. Also, once the array is created, you can explode the inserted objects individually, or move them independently of the other Insert objects. To use the ARRAY command with a block, however, you must first use the INSERT command to create the first object, and then use the ARRAY command to create the desired array.

The disadvantage of using the ARRAY command is that multiple insertions of the block object are made, which therefore increases your drawing's file size.

MEASURE and DIVIDE

The MEASURE and DIVIDE commands provide a method of inserting a block along a path.

MEASURE Command

The MEASURE command enables multiple insertions of a block along a line, arc, or polyline at a given distance. To demonstrate, the next exercise will create a series of rectangles along the centerline of a street design. By creating a block of a rectangle and inserting it at the appropriate distances along the centerline path, a series of templates can quickly be created. These templates can be used to define the various Plan View sections for the street design.

USING MEASURE TO SET A SERIES OF BLOCKS ALONG A PATH

1. Open the 12DWG04.DWG drawing file on the accompanying CD.

This file contains a typical street centerline with right-of-way lines. A block called Viewport exists in the Block Table. This block consists of a rectangle with an insertion base point located in the center of the rectangle. The rectangle is 400 feet wide by 1000 feet long.

You will use the MEASURE command to insert a series of this block every 800 feet along the centerline.


2. Type MEASURE at the command prompt.

3. Select the red centerline.

4. Type B to select block.

5. Type the block name Viewport.

6. Type Y to align the block with the selected object.

7. Enter a segment length of 800.

AutoCAD draws the Viewport block along the centerline path, placing one every 800 feet, as shown in figure 12.10.

Figure 12.10 The MEASURE command places the Viewport block along a path.

DIVIDE Command

The DIVIDE command allows multiple insertions of a block along a line, arc, or polyline any given number of times. Suppose you must draw a series of manholes along the street centerline in the previous example. With the Manhole block already created, you can use the DIVIDE command to insert 30 copies of it along the centerline path.

USING DIVIDE TO INSERT 30 MANHOLE BLOCKS ALONG A PATH

1. Continue with the previous drawing.

2. Type DIVIDE at the command prompt.

3. Select the red centerline.

4. Type B to select block.

5. Type the block name Manhole.

6. Type Y to align the block with the selected object.

7. Enter a segment number of 30.

AutoCAD draws 30 evenly spaced Manhole blocks along the centerline path, as shown in figure 12.11.

Figure 12.11 The DIVIDE command evenly spaces the Manhole block along a path.


NOTE: When inserting blocks into a drawing, it is important to remember that AutoCAD aligns the block's WCS parallel to the current UCS. This feature not only affects the insertion angle of the block, but also affects the rotation angle. If the rotation angle is assigned when a block is inserted, the rotation angle is relative to the current UCS. This is true in both paper space and model space.

Block Reference

Typically, when CAD technicians insert a block, they believe they have created a Block object. Although referring to the inserted object as a block is common, technically it's incorrect. Blocks only reside in the Block Table. When you insert a block, you are actually creating an Insert object. The Insert object references a particular set of block data in the Block Table. This is called a Block reference. AutoCAD uses the Block reference to find the data stored in the Block Table. It uses this data to draw the child objects that make up the Insert object.

Although only one set of data in the Block Table is used to define a block, there can be multiple block references referring to that data. In fact, there is no limit to the number of Insert objects that can be created. In each case, AutoCAD uses the Block reference to find the data it needs to draw the Insert object.

Behavior of Block Properties

There are two properties of blocks that behave in different ways depending on their settings when the block is defined. The color and linetype properties can behave in different but predictable ways when defined on the 0 layer as opposed to other layers. Also, the color and linetypes can be defined explicitly by selecting particular values, or implicitly by defining them as BYLAYER or BYBLOCK.

The Effect of Creating Blocks on a Normal Layer

The simplest way to control the appearance of a block is to define it on a particular layer and explicitly define its color and linetype. For example, suppose you have created a circle object on a layer called circles. To explicitly define its color and linetype, choose Modify, Properties, select the circle, and press Enter. In the Modify Circle dialog box, click on the Color button and select a color from the Select Color dialog box, then click on OK. Then click on the Linetype button and select a linetype from the Select Linetype dialog box, then click on OK. The Modify Circle dialog box now lists the color and linetype you chose as the properties of the circle. You have defined these two values explicitly. As a consequence, if the circle object is used to define a block and the block is inserted into the drawing, its color and linetype will be constant. It will always be the color and linetype you explicitly defined.

In contrast, if the color and linetype are defined implicitly by choosing BYLAYER, these values can be changed by altering the original layer's color and linetype values. For example, suppose the circle object in the previous example has its color and linetype defined as BYLAYER, and the circle object is on the circle's layer when it is used to define a block. When the block is inserted into the drawing, the color and linetype of the circle can be changed by altering the color or linetype of the circle's layer. This is true even if the block is inserted onto a different layer. A child object with its color and linetype properties set to BYLAYER has those properties determined by the values of its original layer.

The Effect of Creating Blocks on Layer 0

The layer 0 has a unique feature. When a block is defined from child objects created on the 0 layer, AutoCAD assigns special properties to that block if its color and linetype properties are set to BYLAYER or BYBLOCK. This feature is powerful.

If BYLAYER is used to define a child object's color and linetype, the layer the block is inserted on controls the child object's color and linetype values.

The following exercise demonstrates how to insert a block whose color and linetype properties have been set to BYLAYER.

INSERTING A BLOCK WITH BYLAYER PROPERTIES

1. Open the 12DWG05.DWG drawing file on the accompanying CD.

The screen is blank, containing no objects. In this drawing file, two blocks are already defined. The block C1 is a circle created on layer 0 with its color and linetype properties set to BYLAYER. The block C2 is a circle created on layer 0 with its color and linetype properties set to BYBLOCK.

Note that on the Object Properties toolbar, the current layer is BLUE, and both color and linetype values are set to BYLAYER.

2. From the Insert menu, choose Block.

3. Click on the Block button.

4. Select the C1 block.

5. Click on OK to close the Defined Blocks dialog box, and click on OK to close the Insert dialog box.

6. Choose a location on the left side of the screen to insert the block. Accept the default values for scale and rotation.

The C1 block is inserted and assumes the color and linetype of the BLUE layer's values.

If BYBLOCK is used to define a child object's color and linetype, the current object's creation values control the child object's color and linetype values. This is true no matter what layer the block is inserted on. These values are controlled from the Object Properties toolbar.

The following exercise demonstrates how to insert the C2 block whose color and linetype properties have been set to BYBLOCK.

INSERTING A BLOCK WITH BYBLOCK PROPERTIES

1. Continue with the 12DWG05.DWG drawing file. From the Object Properties toolbar, change the color property to Magenta and change the linetype property to Hidden2.

2. From the Insert menu, choose Block. The Insert dialog box opens.

3. Click on the Block button. The Defined Blocks dialog box opens.

4. Select the C2 block.

5. Click on OK to close the Defined Blocks dialog box, and click on OK to close the Insert dialog box.

6. Choose a location on the right side of the screen to insert the block and accept the default values for scale and rotation.

Your screen should look similar to figure 12.12. Notice that the C1 block acquired the color and linetype values based on the layers values, while the C2 block acquired the color and linetype values set by the Object Properties toolbar.

Figure 12.12 The effect of BYLAYER versus BYBLOCK.


NOTE: DEFPOINTS is another layer that AutoCAD deals with uniquely. AutoCAD automatically creates this layer any time you draw associative dimensions. The unique property of this layer is that any objects residing on this layer will not be plotted. This is useful because the point objects that AutoCAD uses to control a dimension's value do not need to be plotted, but they are necessary to determine a dimension's value. As a dimension is resized using these point objects, its dimension value is adjusted accordingly. Because these point objects are only necessary to extract a dimension's value, it inserts them on the DEFPOINTS layer, so they won't plot.


WARNING: I have occasionally been frustrated by objects that would not plot, even though I could see them on-screen. The problem was that the objects, including blocks, were accidentally placed on the DEFPOINTS layer.

Understanding Block Attributes

Block attributes are an additional feature of blocks that is very useful. Block attributes store informational data. This data can be defined as a constant value, or can be input by a user at the moment the block is inserted, or edited afterward.


TIP: There is no limit to the number of attributes that can be associated with a block. I have attached 20 or 30 attributes to title sheets. When the title sheet block is inserted into the current drawing, the user is prompted for various values. Sheet number, title, the project engineer's name, the CAD technician's name, and so on. This is useful for guaranteeing that appropriate data is created in a drawing and not accidentally overlooked.

When creating attributes for a block, it is important to control the sequence by which a user is prompted for data. For example, if a block will prompt for a series of data, and this data appears on-screen in alphabetical order, it makes sense to prompt the user for the data in the same order in which it appears on-screen. If you are accustomed to reading from left to right, top to bottom, this is the way you should have attributes prompt for data.

To demonstrate, the following exercise will create two block definitions from a circle object that has five attributes. For the first block, the attributes will be selected from top to bottom. For the second, the attributes will be selected from bottom to top. Finally, the two blocks will be inserted so that you can observe the order in which you are prompted to define values for the attributes.

DETERMINING THE ORDER ATTRIBUTES PROMPT FOR VALUES

1. Open the 12DWG06.DWG drawing file on the accompanying CD.

The drawing already contains the circle and five attributes you will use to define the two blocks.

2. From the Draw menu, choose Block, Make.

3. In the Block Name text box, enter C1.

4. Click on the Select Point button.

5. Use Center osnap, and then select the circle.

6. Click on the Select Objects button.

7. Select the circle object first, and then select each attribute from the top down.

8. Press Enter after you have selected all of the objects.

9. Be sure the Retain Objects box is checked, and then click on OK.

10. From Draw, choose Block, Make.

11. In the Block Name text box, enter C2.

12. Click on the Select Point button.

13. Use Center osnap, and then select the circle.

14. Click on the Select Objects button.

15. Select the circle object first, and then select each attribute from the bottom up.

16. Press Enter after you have selected all of the objects.

17. Be sure the Retain Objects box is not checked, and then click on OK.


Now you will insert the two blocks that were defined to observe the order. You will be prompted to fill in the attributes.

18. From the Insert menu, choose Block.

19. Click on the Block button.

20. Select the C1 block.

21. Click on OK, and OK again.

22. Choose a location near the center of the screen to insert the block and accept the default values for scale and rotation.

23. Enter the numbers 1, 2, 3, 4, and 5 in order when prompted for a value.

AutoCAD inserts the block. The numbers 1, 2, 3, 4, and 5 appear in numerical order from top to bottom.

24. From the Insert menu, choose Block.

25. Click on the Block button.

26. Select the C2 block.

27. Click on OK, and OK again.

28. Choose a location on the right side of the screen to insert the block and accept the default values for scale and rotation.

29. Enter the numbers 1, 2, 3, 4, and 5 in order when prompted for a value.

AutoCAD inserts the block. The numbers 1, 2, 3, 4, and 5 appear in reverse order, as shown in figure 12.13.

Figure 12.13 The effect of the order in which attributes are selected.


NOTE: The order in which attributes prompt for data is affected by the order in which they are selected when being defined. Therefore, their originally defined order is important when using the ATTREDEF command to redefine blocks with attributes.


TIP: To determine the proper order to select attributes when redefining a block, use the LIST command to list one of the block insertions. The order the attributes appear in the list is the order in which they should be selected when redefining the block because this is the order in which they were originally defined.

Using Nested Blocks

As indicated earlier in this chapter, two significant reasons exist for using blocks. The first is to reduce a drawing's file size. The second is to quickly update all the inser-tions of a particular block. For example, suppose you have a block that is made up of a circle with a text object in its center, and you have inserted this particular block hundreds of times. If the text value is currently the letter M, but needs to be changed to S, you can simply redefine the block with the correct letter. Once it is redefined, the hundreds of block insertions are instantly updated with the S text value. This is a very valuable feature that will dramatically increase your productivity.

The previous example demonstrates a powerful feature of blocks. This power can be expanded through the use of nested blocks. A nested block is simply a block that contains other blocks and objects.

Nested blocks increase the power of blocks by making it easier to redefine blocks. For example, suppose you have a block that is made up of 35 objects. If only one of these objects may occasionally change, you can define that object as its own block. Then insert the block and use it to define the complex block, along with the other 34 objects. If it becomes necessary to change that object, you can simply redefine the nested block. Once redefined, the complex block is automatically updated.


WARNING: One problem you must be aware of exists when redefining nested blocks. To redefine a nested block, you must redefine it explicitly in the current drawing. If you redefine a nested block in its parent block outside of the current drawing and then use the INSERT= command to redefine the parent block in the current drawing, the nested blocks won't be updated. AutoCAD only redefines the parent block when you use the INSERT= command. The nested block definitions in the current drawing always take precedence over nested block definitions inserted from another drawing.


TIP: The INSERT= command is a technique that enables you to redefine a nested block. Simply WBLOCK the updated nested block to its own drawing, and use the INSERT= command to redefine the nested block in the necessary drawing.

Managing Blocks Effectively

As you learn how to take advantage of the power of blocks, you will eventually develop hundreds of blocks, possibly more. You can further enhance the power of blocks, by managing those blocks in a fashion that enables you and other users to quickly find the desired block definition. If this is not done, productivity will be lost in one of two ways: First, significant time will be spent trying to simply find the appropriate block. Second, if the block can't be found, time will be spent re-creating the block from scratch. It is therefore necessary to establish criteria that everyone follows to properly create and store blocks for future use.

WBLOCK Command

When creating a block library, the most important component is the block itself. Using the WBLOCK command is a convenient way to quickly extract blocks that have already been defined in existing drawings. Existing drawing files are the first place you should go to develop your block library because they contain the blocks that your organization frequently uses.


NOTE: When inserting a block from outside the current drawing, the Select Drawing File dialog box appears. This dialog box displays the preview image of the highlighted drawing. When a drawing file is made using the WBLOCK command, however, the preview image is not created.

When creating blocks with the WBLOCK command, avoid using characters that AutoCAD doesn't accept for blocks. For example, it may be tempting to use spaces in long file names because of their easy-to-read nature, but AutoCAD will not enable you to insert the block into your current drawing with that name. This occurs because the block's name contains characters acceptable to long file names, but unacceptable to AutoCAD. In this particular case, AutoCAD displays a warning noting that a block name must be less than 32 characters long and contain no spaces. It requires you to rename the block before it will be inserted into the current drawing. These setbacks begin to degrade the efficiency of managing your blocks.


TIP: To create a viewable preview image for the block, open the block's drawing file and then save it. AutoCAD will create the image file and display it when the block's drawing file is highlighted.

Organizing Blocks

The key to managing your block library is to organize the block locations using a well thought out path structure. Store blocks in a standard location on each computer, such as on the C drive under a subdirectory called WORK\BLOCKS. You can further organize blocks into classes and subclasses. The organizational structure should reflect a class structure used in your industry. For example, in civil engineering, it may be useful to organize standard storm drain junction structures using the following path structure:

C:\WORK\BLOCKS\STANDARDS\ORANGE_COUNTY\STORM_DRAIN\
JUNCTION_STRUCTURE-201A\STD-OC-SD-JS-201A.DWG

Following this type of structure, a CAD technician could easily follow the path to find a particular block. If the block was not found with this path structure, it indicates that the block was probably not created yet. Therefore, it can be created in the current drawing, and then WBLOCKed out to the appropriate path location.

Drag and Drop Insertion

By organizing your blocks appropriately, you can easily find blocks using Windows Explorer. You can then insert the block using Windows Drag and Drop feature. For example, simply choose the drawing file's name in Explorer and drag the file name onto the AutoCAD icon in the Windows taskbar. The AutoCAD window will open, and you can insert the block.


NOTE: If the block name contains characters that AutoCAD does not accept for blocks or xrefs, AutoCAD will display the Substitute Block Name dialog box. You must then provide a new name for the block using the appropriate characters.

Image Tile Menus

AutoCAD provides a fairly simple way to create preview images of blocks. By using Image Tile Menus, you can visually display previews of hundreds of blocks, 20 images at a time. The Image Tile Menu dialog box can be easily customized for use with blocks. When the Image Tile Menu is displayed, the user simply chooses the desired block. Once selected, the INSERT command is automatically executed with the selected block.

For example, figure 12.14 shows an Image Tile Menu that took only a few minutes to create. The images are from the six ANSI drawing files that come with AutoCAD. They are found in Release 14's parent directory. The ACAD.MNU file was modified as follows by adding the following text:

**image_Borders
[Standard Sheet Borders]
[borders(ansi_a,ANSI A Border)]^C^C_insert "ansi_a"
[borders(ansi_b,ANSI B Border)]^C^C_insert "ansi_b"
[borders(ansi_c,ANSI C Border)]^C^C_insert "ansi_c"
[borders(ansi_d,ANSI D Border)]^C^C_insert "ansi_d"
[borders(ansi_e,ANSI E Border)]^C^C_insert "ansi_e"
[borders(ansi_v,ANSI V Border)]^C^C_insert "ansi_v"

This text simply tells AutoCAD where to find the images to display in the menu's tiles, and the command to execute when one of the tiles is selected. In this case, the INSERT command will be selected and the appropriate drawing file will be used. You will find a detailed discussion of Image Tile Menus in Chapter 23, "Creating Scripts and Slide Libraries."

Figure 12.14 The customized Image Tile Menu.

Summary

Blocks are a very powerful feature of AutoCAD. This chapter has shown you how to extract the power of blocks by explaining the nature of blocks. You learned what happens to AutoCAD's database when a block is defined, and how the current UCS affects a block when it's being defined or inserted. You learned how AutoCAD stores a block definition in the block table, and how it references the block table to create the insert object. You saw the effects of defining blocks on a normal layer and on layer 0, and the difference between explicitly and implicitly defining the color and linetype properties of a block. The advantages of creating complex blocks from simpler blocks were discussed, and the steps necessary to redefine nested blocks with the INSERT= command were explained. Several techniques for managing block libraries, which enable you to quickly find the block you need, were presented.

By understanding how blocks work, and how to properly manage blocks, you have learned how to make AutoCAD do tedious, repetitious drafting work automatically to increase your productivity.


Previous chapterNext chapterContents

© Copyright, Macmillan Computer Publishing. All rights reserved.